package com.corpgovernment.common.validation;

import com.corpgovernment.common.enums.CodeEnum;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import javax.validation.Constraint;
import javax.validation.Payload;


/**
 * 校验入参中传的枚举类型
 */
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = CodeEnumValidator.class)
@Target({ElementType.FIELD, ElementType.PARAMETER})
public @interface ValidCodeEnum {

    String message() default "参数不合法";

    Class<?>[] groups() default { };

    Class<? extends Payload>[] payload() default { };

    /**
     * 支持的枚举类型，需要为{@link CodeEnum}的实现类，会校验入参是否在枚举的code范围内
     */
    Class<? extends Enum<?>> supportCodeEnum();

    /**
     * 参数是否支持为空字符串或null
     */
    boolean canBlank() default false;
}